<template>
	<view class="zai-box">
		<image src="../../static/login.png" mode='aspectFit' class="zai-logo"></image>
		<view class="zai-title">LOGO区域</view>
		<view class="zai-form">
			<input class="zai-input" v-model="mobile" placeholder-class placeholder="请输入手机号" />
			<input class="zai-input" v-model="password" placeholder-class password placeholder="请输入密码" />
			<view class="zai-label">忘记密码？</view>
			<button class="zai-btn" @tap="handleLogin">立即登录</button>
			<navigator url="../register/register" hover-class="none" class="zai-label">还没有账号？点此注册.</navigator>
		</view>
	</view>
</template>

<script>
	import {
		mapActions,
		mapState,
		mapGetters,
		mapMutations
	} from 'vuex';
	export default {
		data() {
			return {
				mobile: 18208925160,
				password: 123456
			}
		},
		onLoad() {

		},
		onShow() {

		},
		methods: {
			...mapMutations(['LIVE_LOGIN']),
			handleLogin() {
				let _this = this;
				if (!_this.mobile) {
					_this.$mUtils.tip('请输入手机号', 800)
					return
				} else if (!_this.$mUtils.mobileReg(_this.mobile)) {
					_this.$mUtils.tip('请输入正确手机号', 800)
					return
				} else if (!_this.password) {
					_this.$mUtils.tip('请输入密码', 800)
					return
				} else {
					console.log("还有第三种情况~~~~")
				}
				uni.request({
					url: 'http://118.25.83.185/api/live/login',
					data: {
						mobile: this.mobile,
						password: this.password
					},
					header: {},
					success: (res) => {
						console.log(res)
						if (res.data.code == 1) {
							_this.$mUtils.tip(res.data.msg, 800)
							setTimeout(function() {
								uni.reLaunch({
								    url: '../my/my'
								});
							}, 600)
							_this.LIVE_LOGIN(res.data.data)
							_this.$mUtils.setStorageSync('LIVE_LOGIN', res.data.data);
						} else if (res.data.code == 0) {
							_this.$mUtils.tip(res.msg)
						} else {
							_this.$mUtils.tip(res.msg)
						}
					}
				});
			}
		}
	}
</script>

<style>
	.zai-box {
		padding: 0 100upx;
		position: relative;
	}

	.zai-logo {
		width: 100%;
		width: 100%;
		height: 310upx;
	}

	.zai-title {
		position: absolute;
		top: 0;
		line-height: 360upx;
		font-size: 68upx;
		color: #fff;
		text-align: center;
		width: 100%;
		margin-left: -100upx;
	}

	.zai-form {
		margin-top: 300upx;
	}

	.zai-input {
		background: #e2f5fc;
		margin-top: 30upx;
		border-radius: 100upx;
		padding: 20upx 40upx;
		font-size: 36upx;
	}

	.input-placeholder,
	.zai-input {
		color: #94afce;
	}

	.zai-label {
		padding: 60upx 0;
		text-align: center;
		font-size: 30upx;
		color: #a7b6d0;
	}

	.zai-btn {
		background: #ff65a3;
		color: #fff;
		border: 0;
		border-radius: 100upx;
		font-size: 36upx;
	}

	.zai-btn:after {
		border: 0;
	}

	/*按钮点击效果*/
	.zai-btn.button-hover {
		transform: translate(1upx, 1upx);
	}
</style>
